<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <style>
        .layui-input-block input{
            width:200px;
        }

    </style>
</head>
<body>

<form class="layui-form" action="" style = "margin-top:30px;">
    <div class="layui-form-item">
        <label class="layui-form-label">问题:</label>
        <div class="layui-input-block">
            <input id="wenti" type="text" name="wenti" class="layui-input" value="{$list.wenti}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话:</label>
        <div class="layui-input-block">
            <input id="phone" type="number" name="phone" class="layui-input" value="{$list.phone}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">回答:</label>
        <div class="layui-input-block">
            <!--<input id="order" type="number" name="order" class="layui-input" value="{$list.order}">-->
            <input id="answer" type="text" name="answer" class="layui-input" value="{$list.answer}">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
        </div>
    </div>
    <input id="id" name = "id" type="hidden" value="{$list.id}">
</form>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    // var editor = UE.getEditor('container');
</script>
<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__PUBLIC__/js/jquery-1.11.1.min.js" charset="utf-8"></script>
<script type="text/javascript">
    layui.use(['element','laypage','laytpl','layer','upload', 'form'], function(){
        var upload = layui.upload,layer=layui.layer,form = layui.form,$=layui.jquery;
        //执行实例
        var uploadInst = upload.render({
            elem: '#img' //绑定元素
            ,url: '{:U("uploadFile")}' //上传接口
            ,multiple:false
            ,done: function(res){
                //上传完毕回调
                // layer.alert(res.url)
                $("#imglist").empty();
                $("#imglist").append("<img src = "+res.url+" style = 'width:150px;height:250px;'/>");
                $("#imglist").append("<input type = 'hidden' id = 'img_file' name = 'img_file' value = '"+res.url+"'/>");
            }
            ,error: function(){
                //请求异常回调
                layer.alert(res)
            }
        });
        form.on('submit(formDemo)', function(data){
            // layer.msg(JSON.stringify(data.field));
            if(''==data.field.order || parseInt(data.field.order)<=0){
                layer.alert('顺序大于0');
                return false;
            }
            $.post('{:U("save")}',data.field,function(e){
                // layer.alert(e);
                if(1 == e){
                    layer.alert('修改成功');
                    setTimeout(function(){
                        window.parent.location.reload();
                    },2000);
                }else{
                    layer.alert('修改失败');
                }
            })
            return false;
        });
    });
</script>
</body>
</html>